<?php
	//Requires database	
	require_once('includes.php');
	include_once('check_login_function.php');
	
	//This function is used in for admins
	
	//Enter a new hospital
	if (isset($_POST['enterHospital'])) {
		$hospital_name = $_POST['name'];
		$hospital_address = $_POST['address'];
		$hospital_contact = $_POST['contact'];
		
		$hospital = new Hospital($hospital_name, $hospital_address, $hospital_contact);
		$hospital->insert();
		header('Location: ' . DIR . '/' . $_POST['from']);
	}
	
	//Delete hospital
	if (isset($_POST['deleteHospital'])) {
		$hospital_id = intval($_POST['hospitalID']);
		
		$hospital = Hospital::createHospital($hospital_id);
		$hospital->remove();
		header('Location: ' . DIR . '/' . $_POST['from']);
	}

	//Clear all users from the hospital
	if (isset($_POST['clearHospital'])) {
		$hospital_id = intval($_POST['hospitalID']);
		
		$hospital = Hospital::createHospital($hospital_id);
		$hospital->unattachFromUsers();
		header('Location: ' . DIR . '/' . $_POST['from']);
	}	
	
	//Enter a new notification type
	if (isset($_POST['enterNotificationType'])) {
		$type_name = $_POST['typename'];
		Notification::addType($type_name);
		header('Location: ' . DIR . '/' . $_POST['from']);
	}
	
	//Delete a notification type
	if (isset($_POST['deleteNotificationType'])) {
		$logtype_id = intval($_POST['notificationTypeID']);
		Notification::removeType($logtype_id);
		header('Location: ' . DIR . '/' . $_POST['from']);
	}
	
	//Enter a new log type	
	if (isset($_POST['enterLogType'])) {
		$type_name = $_POST['typename'];
		DataLog::addType($type_name);	
		header('Location: ' . DIR . '/' . $_POST['from']);	
	}	
	
	//Delete a log type
	if (isset($_POST['deleteLogType'])) {
		$logtype_id = intval($_POST['logTypeID']);
		DataLog::removeType($logtype_id);
		header('Location: ' . DIR . '/' . $_POST['from']);
	}
	
	//Verify doctor
	if (isset($_POST['verifyDoctor'])) {
		$doctor_id = intval($_POST['doctorID']);
		Doctor::changeVerified($doctor_id, true);
		header('Location: ' . DIR . '/' . $_POST['from']);
	}
	//Unverify doctor
	if (isset($_POST['unverifyDoctor'])) {
		$doctor_id = intval($_POST['doctorID']);	
		Doctor::changeVerified($doctor_id, false);
		header('Location: ' . DIR . '/' . $_POST['from']);
	}		
?>